package msl.ConAR;


import java.util.*;

import android.app.Activity;
import android.content.*;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
import msl.ConAR.*;
import msl.ConAR.R.*;

public class CoworkerTab extends Activity{
	
	ArrayList<MyCoworker> arCoworker;
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.coworkerlist);
		
		arCoworker = new ArrayList<MyCoworker>();
		MyCoworker mcoworker;
		
		mcoworker=new MyCoworker(R.drawable.bsw, "Sungwook Baek", "SNS", "Android for OpenCV"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.lhk, "Haekwang Lee", "Context-Aware", "Entertainment Apps"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.sjh, "Jonghoon Seo", "Text Entry", "cvARTK : Augmented Reality"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.jsc, "Soonchul Jang", "Media Arts", "KiNECT Arts"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.cjh, "Jihae Choi", "TableTop", "Human-Pet Interaction"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.pjames, "James Park", "Hand Gesture", "Hand-Gesture"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.kjm, "Jemin Kim", "Embedded System", "Android System"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.jsh, "Soohyun Jo", "Interaction", "Keyboard Interface"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.shn, "Hyungnam Shim", "Software Engineering", "Face Recognition Project"); arCoworker.add(mcoworker);
		mcoworker=new MyCoworker(R.drawable.jyh, "Yoonhae Jung", "3D Graphics", "CUDA Application"); arCoworker.add(mcoworker);
		
		MyCoworkerListAdapter MyAdapter=new MyCoworkerListAdapter(
				this, R.layout.coworker, arCoworker);
		
		ListView MyList;
		MyList=(ListView)findViewById(R.id.cwlist);
		MyList.setAdapter(MyAdapter);
				
	}
}

class MyCoworker{
	MyCoworker(int aIcon, String aName, String aResearch, String aProject){
		Icon=aIcon;
		Name=aName;
		Research=aResearch;
		Project=aProject;
	}
	
	int Icon;
	String Name;
	String Research;
	String Project;
	
}

class MyCoworkerListAdapter extends BaseAdapter{
	
	Context maincon;
	LayoutInflater Inflater;
	ArrayList<MyCoworker> arSrc;
	int layout;
	
	public MyCoworkerListAdapter(Context context, int alayout, ArrayList<MyCoworker> aarSrc){
		maincon=context;
		Inflater=(LayoutInflater)context.getSystemService(
				Context.LAYOUT_INFLATER_SERVICE);
		
		arSrc=aarSrc;
		layout=alayout;
	}
	
	public int getCount(){
		return arSrc.size();
	}
	
	public String getItem(int position){
		return arSrc.get(position).Name;
		
	}

	public long getItemId(int position){
		return position;
	}
	
	//뷰 생성
	public View getView(int position, View convertView, ViewGroup parent){
		final int pos=position;
		if(convertView==null){
			convertView=Inflater.inflate(layout, parent, false);
		}
		
		ImageView img=(ImageView)convertView.findViewById(R.id.cwImg);
		img.setImageResource(arSrc.get(position).Icon);
		
		TextView txtName=(TextView)convertView.findViewById(R.id.cwNameText);
		txtName.setText("Name : " + arSrc.get(position).Name);
		
		TextView txtResearch=(TextView)convertView.findViewById(R.id.cwResearchText);
		txtResearch.setText("Research Fields : " + arSrc.get(position).Research);
		
		TextView txtProject=(TextView)convertView.findViewById(R.id.cwProjectText);
		txtProject.setText("Projects : " + arSrc.get(position).Project);
		
		return convertView;
				
	}
}
